<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>vimrc | 学习笔记</title><meta name="author" content="lzoxun"><meta name="copyright" content="lzoxun"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="配置文件 and 插件管理第三方配置vimplus安 装 插件管理器vimplus ~&#x2F;.vimrc为vimplus的默认配置，一般不做修改 ~&#x2F;.vimrc.custom.plugins为用户自定义插件列表，用户增加、卸载插件请修改该文件 ~&#x2F;.vimrc.custom.config为用户自定义配置文件，一般性配置请放入该文件，可覆盖~&#x2F;.vimrc 里的配置   插件存放在 ~&#x2F;.v">
<meta property="og:type" content="article">
<meta property="og:title" content="vimrc">
<meta property="og:url" content="http://example.com/2023/07/22/linux/linux-vimrc/index.html">
<meta property="og:site_name" content="学习笔记">
<meta property="og:description" content="配置文件 and 插件管理第三方配置vimplus安 装 插件管理器vimplus ~&#x2F;.vimrc为vimplus的默认配置，一般不做修改 ~&#x2F;.vimrc.custom.plugins为用户自定义插件列表，用户增加、卸载插件请修改该文件 ~&#x2F;.vimrc.custom.config为用户自定义配置文件，一般性配置请放入该文件，可覆盖~&#x2F;.vimrc 里的配置   插件存放在 ~&#x2F;.v">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png">
<meta property="article:published_time" content="2023-07-22T07:14:09.681Z">
<meta property="article:modified_time" content="2023-07-22T07:14:09.681Z">
<meta property="article:author" content="lzoxun">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2023/07/22/linux/linux-vimrc/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":true,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'vimrc',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-22 15:14:09'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="学习笔记"><span class="site-name">学习笔记</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">vimrc</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-22T07:14:09.681Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-22T07:14:09.681Z" title="更新于 2023-07-22 15:14:09">2023-07-22</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="vimrc"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="配置文件-and-插件管理"><a href="#配置文件-and-插件管理" class="headerlink" title="配置文件 and 插件管理"></a>配置文件 and 插件管理</h2><h3 id="第三方配置"><a href="#第三方配置" class="headerlink" title="第三方配置"></a>第三方配置</h3><h2 id="vimplus"><a href="#vimplus" class="headerlink" title="vimplus"></a>vimplus</h2><h3 id="安-装"><a href="#安-装" class="headerlink" title="安 装"></a>安 装</h3><ul>
<li>插件管理器<code>vimplus</code><ul>
<li><code>~/.vimrc为vimplus</code>的默认配置，一般不做修改</li>
<li><code>~/.vimrc.custom.plugins</code>为用户自定义插件列表，用户增加、卸载插件请修改该文件</li>
<li><code>~/.vimrc.custom.config</code>为用户自定义配置文件，一般性配置请放入该文件，可覆盖~&#x2F;.vimrc 里的配置</li>
</ul>
</li>
<li>插件存放在 <code>~/.vim/plugged</code>下</li>
<li>新插件可以直接复制进去或 vim 中执行<code>:PlugInstall</code>进行安装</li>
<li><a target="_blank" rel="noopener" href="https://github.com/chxuan/vimplus">github</a></li>
</ul>
<h3 id="插件"><a href="#插件" class="headerlink" title="插件"></a>插件</h3><h4 id="scrooloose-nerdtree"><a href="#scrooloose-nerdtree" class="headerlink" title="scrooloose&#x2F;nerdtree"></a>scrooloose&#x2F;nerdtree</h4><blockquote>
<p>当于常用的 IDE 中的工程栏可以帮助我们管理和管理切换文件</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">Plug &#x27;scrooloose/nerdtree&#x27;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">,+n 打开</span></span><br><span class="line">&quot;:NERDTreeToggle&lt;cr&gt;   &quot;打开或关闭nerdtree，可自定义映射热键</span><br><span class="line">autocmd vimenter * NERDTree     &quot;默认为打开nerdtree</span><br><span class="line">let NERDTreeShowLineNumbers=1                   &quot;显示行号</span><br><span class="line">let NERDTreeShowHidden=1                        &quot;宽度为1</span><br><span class="line">let NERDTreeIgnore=[&#x27;\.pyc&#x27;,&#x27;\~$&#x27;,&#x27;\.swp&#x27;]      &quot;忽略以下文件</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">文件操作</span></span><br><span class="line">m</span><br><span class="line">    d:删除</span><br><span class="line">    a:添加文件/文件夹（加斜杠）</span><br><span class="line">    m:移动或改名</span><br><span class="line">    o:打开gui</span><br><span class="line">C:设置当前目录为项目根目录</span><br><span class="line">//常用操作</span><br><span class="line">h j k l移动光标定位</span><br><span class="line">ctrl+w+w 光标在左右窗口切换</span><br><span class="line">ctrl+w+r 切换当前窗口左右布局</span><br><span class="line">ctrl+p 模糊搜索文件</span><br><span class="line"></span><br><span class="line">gT 切换到前一个tab</span><br><span class="line">g t 切换到后一个tab</span><br><span class="line">u 打开上层目录</span><br><span class="line">o|O打开关闭文件或者目录，如果是文件的话，光标出现在打开的文件中</span><br><span class="line">x 合拢当前结点的父目录</span><br><span class="line">I:显示/隐藏,隐藏文件文件</span><br><span class="line">i和s将光标指向文件以水平分割或纵向分割窗口打开</span><br></pre></td></tr></table></figure>

<h4 id="vim-airline-状态栏"><a href="#vim-airline-状态栏" class="headerlink" title="vim-airline(状态栏)"></a>vim-airline(状态栏)</h4><h4 id="auto-pairs-“成对符号自动匹配输入”"><a href="#auto-pairs-“成对符号自动匹配输入”" class="headerlink" title="auto-pairs(“成对符号自动匹配输入”)"></a>auto-pairs(“成对符号自动匹配输入”)</h4><h4 id="vimplus-startify-启动界面美化"><a href="#vimplus-startify-启动界面美化" class="headerlink" title="vimplus-startify(启动界面美化)"></a>vimplus-startify(启动界面美化)</h4><h3 id="我的插件【https-vim-hizdm-cn-language-coc-vetur-html】"><a href="#我的插件【https-vim-hizdm-cn-language-coc-vetur-html】" class="headerlink" title="我的插件【https://vim.hizdm.cn/language/coc-vetur.html】"></a>我的插件【<a target="_blank" rel="noopener" href="https://vim.hizdm.cn/language/coc-vetur.html%E3%80%91">https://vim.hizdm.cn/language/coc-vetur.html】</a></h3><ul>
<li><p><a target="_blank" rel="noopener" href="https://github.com/mattn/emmet-vim">emmet-vim</a></p>
<ul>
<li><code>ctrl-y 加 ,</code>:生成规则标签，相当于 tab</li>
<li><code>ctrl-y 加 d</code>:插入模式下，选中整个标签</li>
<li><code>ctrl-y 加 /</code>:插入模式下，注释整个标签</li>
<li><code>ctrl-y 加 k</code>:插入模式下，删除整个标签</li>
</ul>
</li>
<li><p>格式化</p>
<ul>
<li><p>通用格式化</p>
<ul>
<li>vim-autoformat <a target="_blank" rel="noopener" href="https://www.cnblogs.com/liuzhaoting/articles/13794745.html">参考</a></li>
</ul>
</li>
<li><p>vue 相关</p>
<ul>
<li><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_34342578/article/details/89567263">参考</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1. 语法高亮：posva/vim-vue</span><br><span class="line">2. 语法检查：vim-syntastic/syntastic  + eslint-plugin-vue</span><br><span class="line">3. 代码格式化：MaraniMatias/vue-formatter</span><br><span class="line"></span><br><span class="line">npm install -g prettier -&gt; https://zhuanlan.zhihu.com/p/34428176</span><br><span class="line">npm install -g vue-formatter</span><br></pre></td></tr></table></figure>

<h3 id="快捷键-默认"><a href="#快捷键-默认" class="headerlink" title="快捷键(默认)"></a>快捷键(默认)</h3><p><a target="_blank" rel="noopener" href="https://github.com/chxuan/vimplus">参考</a></p>
<table>
<thead>
<tr>
<th align="center">快捷键</th>
<th align="center">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center">,</td>
<td align="center">leader key</td>
</tr>
<tr>
<td align="center">leader + n</td>
<td align="center">菜单,资源管理器</td>
</tr>
<tr>
<td align="center">leader + f</td>
<td align="center">查找目录下文件</td>
</tr>
<tr>
<td align="center">leader + F</td>
<td align="center">查找当前目录下文件</td>
</tr>
<tr>
<td align="center">leader + g</td>
<td align="center">显示 git 提交记录</td>
</tr>
<tr>
<td align="center">leader + G</td>
<td align="center">显示当前文件提交记录</td>
</tr>
<tr>
<td align="center">F9&#x2F;F10</td>
<td align="center">上下切换主题</td>
</tr>
<tr>
<td align="center">leader + G</td>
<td align="center">显示当前文件提交记录</td>
</tr>
<tr>
<td align="center">f+a</td>
<td align="center">查找字母 a,继续 f，下一个</td>
</tr>
<tr>
<td align="center">gcc&#x2F;gc&#x2F;gcap</td>
<td align="center">注释一行代码&#x2F;注释选中所在行的代码&#x2F;段落</td>
</tr>
<tr>
<td align="center">leader + e</td>
<td align="center">打开 .vimrc</td>
</tr>
<tr>
<td align="center">leader + vc</td>
<td align="center">.vimrc.custom.config</td>
</tr>
<tr>
<td align="center">leader + vp</td>
<td align="center">.vimrc.custom.plugins</td>
</tr>
<tr>
<td align="center">leader + s</td>
<td align="center">重新加载 .vimrc</td>
</tr>
<tr>
<td align="center">leader + leader + i</td>
<td align="center">安装插件</td>
</tr>
<tr>
<td align="center">leader + leader + u</td>
<td align="center">更新插件</td>
</tr>
<tr>
<td align="center">leader + leader + c</td>
<td align="center">删除插件</td>
</tr>
<tr>
<td align="center">leader + F</td>
<td align="center">全局搜索目录或文件下的单词</td>
</tr>
</tbody></table>
<h3 id="异常i"><a href="#异常i" class="headerlink" title="异常i"></a>异常i</h3><ul>
<li><code>The ycmd server SHUT DOWN (restart with &#39;:YcmRestartServer&#39;). YCM core library not detected; you need to compile YCM before using it. Follow the instructions in the documentation.</code><ul>
<li>解决: 进入<code>.vim</code>插件下找到<code>YcmRestartServer</code>插件,执行里面的<code>install.py</code></li>
</ul>
</li>
</ul>
<h2 id="vim-配置文件"><a href="#vim-配置文件" class="headerlink" title="vim 配置文件"></a>vim 配置文件</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">set</span> nu <span class="string">&quot;行号</span></span><br><span class="line"><span class="string">set clipboard=unnamed &quot;</span>vim与外界相互复制,vim --version | grep clipboard 查看是否支持，不支持可以安装gvim</span><br><span class="line"><span class="built_in">set</span> hlsearch <span class="string">&quot;搜索匹配的高亮</span></span><br><span class="line"><span class="string">set cursorline &quot;</span>行下划线</span><br><span class="line"><span class="built_in">set</span> noswapfile <span class="string">&quot;意外关闭不需要wap文件</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">set softtabstop=4 &quot;</span>tab的步长</span><br><span class="line"><span class="built_in">set</span> shiftwidth=<span class="number">4</span> <span class="string">&quot;&gt;&gt;&lt;&lt;缩进的步长</span></span><br><span class="line"><span class="string">set expandtab &quot;</span>设置可把tab转成空格 :retab 可以直接重置</span><br><span class="line"><span class="built_in">set</span> showtabline=<span class="number">1</span> <span class="string">&quot;tabe的标签页 0:不会出现页签、1:大于1页出现、2:只有1页也出现</span></span><br><span class="line"><span class="string">set splitbelow &quot;</span>new分屏时，新页面在下</span><br><span class="line"><span class="built_in">set</span> splitright <span class="string">&quot;vnew分屏时，新页面在右</span></span><br><span class="line"><span class="string">set ignorecase &quot;</span>搜索无视大小写</span><br><span class="line"><span class="built_in">set</span> incsearch <span class="string">&quot;搜索时匹配到的直接高亮,不要的回车</span></span><br><span class="line"><span class="string">set ruler &quot;</span>行列位置标注</span><br><span class="line"><span class="built_in">set</span> warp <span class="string">&quot;可折行</span></span><br><span class="line"><span class="string">set showcmd &quot;</span>查看按键</span><br><span class="line"><span class="built_in">set</span> showmode <span class="string">&quot;状态栏查看模式</span></span><br><span class="line"><span class="string">set scrolloff=3 &quot;</span>距离上下多少开始滚动</span><br><span class="line"><span class="built_in">set</span> <span class="built_in">list</span> <span class="string">&quot;显示一下隐藏符号</span></span><br><span class="line"><span class="string">autocmd 一个事件 *文件 :set xxx &quot;</span>符合某个条件做什么事情</span><br><span class="line"><span class="string">&quot;:set all 查看所以可以用的设定</span></span><br><span class="line"><span class="string">set autoread vim内文件内容变化自动更新</span></span><br><span class="line"><span class="string">set autowriteall 切换文件自动保存</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&quot;</span> color</span><br><span class="line">syntax on <span class="string">&quot;开启语法高亮</span></span><br><span class="line"><span class="string">&quot;</span>colorscheme default</span><br><span class="line">colorscheme darkxxxx <span class="string">&quot;指定主题</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&quot;</span> filetype 读取文件类型，o新增行时自动缩进</span><br><span class="line">filetype on</span><br><span class="line">filetype indent on</span><br><span class="line">filetype plugin on</span><br><span class="line"></span><br><span class="line"><span class="string">&quot;:h key-notation  查看自定义键位表示方法</span></span><br><span class="line"><span class="string">&quot;</span>:<span class="built_in">map</span>  查看<span class="built_in">map</span>的相关定义</span><br><span class="line"><span class="string">&quot; map|unmap  一般模式、选择模式键位设置</span></span><br><span class="line"><span class="string">&quot;</span> nmap|nunmap 一般模式</span><br><span class="line"><span class="string">&quot; vmap|vunmap 选择模式</span></span><br><span class="line"><span class="string">&quot;</span> imap|iunmap 插入模式</span><br><span class="line">nmap &lt;C-v&gt; p <span class="string">&quot;一般模式下 ctrl+v 的功能设置成粘贴</span></span><br><span class="line"><span class="string">nmap &lt;Tab&gt; &gt;&gt; &quot;</span>一般模式下 Tab 的功能设置成缩进</span><br><span class="line"></span><br><span class="line"><span class="string">&quot; noremap 与 map作用类似但是避免死循环问题</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&quot;</span> <span class="keyword">try</span></span><br><span class="line"><span class="keyword">try</span></span><br><span class="line">  error</span><br><span class="line">catch</span><br><span class="line">  xxx</span><br><span class="line">endtry</span><br><span class="line"></span><br><span class="line"><span class="string">&quot; 引入外部文件</span></span><br><span class="line"><span class="string">source  $HOME/xxxx.vim &quot;</span>将配置模块话到一个个vim文件中</span><br></pre></td></tr></table></figure>

<h3 id="diff-对比差异"><a href="#diff-对比差异" class="headerlink" title="diff 对比差异"></a>diff 对比差异</h3><blockquote>
<p>将代码复制到.vimrc或相关配置文件中<br><strong>保存前</strong> <code>:DiffSaved</code> 查看差异，<code>:q</code> 退出，<code>:diffoff</code> 退出差异视图</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">function! s:DiffWithSaved()</span><br><span class="line">    let filetype=&amp;ft</span><br><span class="line">    diffthis</span><br><span class="line">    vnew | r # | normal! 1Gdd</span><br><span class="line">    diffthis</span><br><span class="line">    exe &quot;setlocal bt=nofile bh=wipe nobl noswf ro ft=&quot; . filetype</span><br><span class="line">endfunction</span><br><span class="line">com! DiffSaved call s:DiffWithSaved()</span><br></pre></td></tr></table></figure>

<h3 id="vscodevim"><a href="#vscodevim" class="headerlink" title="vscodevim"></a>vscodevim</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line"></span><br><span class="line">    //设置 leader键</span><br><span class="line">    &quot;vim.leader&quot;: &quot;,&quot;,</span><br><span class="line">    //取消vim插件某些功能使用vscode自带功能</span><br><span class="line">    &quot;vim.handleKeys&quot;: &#123;</span><br><span class="line">        &quot;&lt;C-a&gt;&quot;: false,</span><br><span class="line">        &quot;&lt;C-f&gt;&quot;: false,</span><br><span class="line">        &quot;&lt;C-n&gt;&quot;: false</span><br><span class="line">    &#125;,</span><br><span class="line">    //普通模式下非递归键位绑定，在原生vim中是noremap</span><br><span class="line">    &quot;vim.normalModeKeyBindingsNonRecursive&quot;:[</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;Enter&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;o&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;: [&quot;&lt;Leader&gt;&quot;, &quot;t&quot;, &quot;t&quot;],</span><br><span class="line">            &quot;commands&quot;: [&quot;:tabnew&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;Tab&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;Shift&gt;&quot;,&quot;&gt;&quot;,&quot;&gt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;S-Tab&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;Shift&gt;&quot;,&quot;&lt;&quot;,&quot;&lt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">    ],</span><br><span class="line">    //命令行模式非递归键位绑定，在原生vim中等同于norecmap</span><br><span class="line">    &quot;vim.commandLineModeKeyBindingsNonRecursive&quot;: [</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    ],</span><br><span class="line">    //指的是插入模式下键位绑定，在原生vim里面指的是imap</span><br><span class="line">    &quot;vim.insertModeKeyBindings&quot;:[</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;C-h&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;Left&gt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;C-l&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;Right&gt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;C-j&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;Down&gt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;C-k&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;Up&gt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;j&quot;,&quot;j&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;Esc&gt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;before&quot;:[&quot;&lt;S-j&gt;&quot;],</span><br><span class="line">            &quot;after&quot;:[&quot;&lt;BS&gt;&quot;]</span><br><span class="line">        &#125;,</span><br><span class="line">    ],</span><br><span class="line">    &quot;vim.commandLineModeKeyBindings&quot;: [</span><br><span class="line"></span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">lzoxun</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2023/07/22/linux/linux-vimrc/">http://example.com/2023/07/22/linux/linux-vimrc/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">学习笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/07/22/linux/linux-vim/" title="vim"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">vim</div></div></a></div><div class="next-post pull-right"><a href="/2023/07/22/linux/linux-vimscript/" title="vimscript"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">vimscript</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">lzoxun</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/liaozhongxun"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/liaozhongxun" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:869664233@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">这是我的文档</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-and-%E6%8F%92%E4%BB%B6%E7%AE%A1%E7%90%86"><span class="toc-number">1.</span> <span class="toc-text">配置文件 and 插件管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%AC%AC%E4%B8%89%E6%96%B9%E9%85%8D%E7%BD%AE"><span class="toc-number">1.1.</span> <span class="toc-text">第三方配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vimplus"><span class="toc-number">2.</span> <span class="toc-text">vimplus</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89-%E8%A3%85"><span class="toc-number">2.1.</span> <span class="toc-text">安 装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8F%92%E4%BB%B6"><span class="toc-number">2.2.</span> <span class="toc-text">插件</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#scrooloose-nerdtree"><span class="toc-number">2.2.1.</span> <span class="toc-text">scrooloose&#x2F;nerdtree</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#vim-airline-%E7%8A%B6%E6%80%81%E6%A0%8F"><span class="toc-number">2.2.2.</span> <span class="toc-text">vim-airline(状态栏)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#auto-pairs-%E2%80%9C%E6%88%90%E5%AF%B9%E7%AC%A6%E5%8F%B7%E8%87%AA%E5%8A%A8%E5%8C%B9%E9%85%8D%E8%BE%93%E5%85%A5%E2%80%9D"><span class="toc-number">2.2.3.</span> <span class="toc-text">auto-pairs(“成对符号自动匹配输入”)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#vimplus-startify-%E5%90%AF%E5%8A%A8%E7%95%8C%E9%9D%A2%E7%BE%8E%E5%8C%96"><span class="toc-number">2.2.4.</span> <span class="toc-text">vimplus-startify(启动界面美化)</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%88%91%E7%9A%84%E6%8F%92%E4%BB%B6%E3%80%90https-vim-hizdm-cn-language-coc-vetur-html%E3%80%91"><span class="toc-number">2.3.</span> <span class="toc-text">我的插件【https:&#x2F;&#x2F;vim.hizdm.cn&#x2F;language&#x2F;coc-vetur.html】</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BF%AB%E6%8D%B7%E9%94%AE-%E9%BB%98%E8%AE%A4"><span class="toc-number">2.4.</span> <span class="toc-text">快捷键(默认)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%82%E5%B8%B8i"><span class="toc-number">2.5.</span> <span class="toc-text">异常i</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vim-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">3.</span> <span class="toc-text">vim 配置文件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#diff-%E5%AF%B9%E6%AF%94%E5%B7%AE%E5%BC%82"><span class="toc-number">3.1.</span> <span class="toc-text">diff 对比差异</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#vscodevim"><span class="toc-number">3.2.</span> <span class="toc-text">vscodevim</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-11/" title="win 11 set">win 11 set</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-gitbash/" title="git bash">git bash</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-wsl/" title="wsl">wsl</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-main/" title="window">window</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/web/%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98/" title="兼容问题">兼容问题</a><time datetime="2023-07-22T07:14:09.699Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By lzoxun</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><div class="js-pjax"></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div class="no-result" id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/haruto.model.json"},"display":{"position":"right","width":100,"height":200,"right":300},"mobile":{"show":true}});</script></body></html>